package com.ruoyi.web.controller.systembasic;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mes.systembasic.domain.SmesSequenceProduce;
import com.ruoyi.mes.systembasic.service.ISmesSequenceProduceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 自动生成序列管理Controller
 *
 * @author simpsense
 * @date 2020-12-11
 */
@RestController
@RequestMapping("/systembasic/produceSequence")
public class SmesSequenceProduceController extends BaseController
{
    @Autowired
    private ISmesSequenceProduceService smesSequenceProduceService;

    /**
     * 查询自动生成序列管理列表
     */
    @PreAuthorize("@ss.hasPermi('systembasic:produceSequence:list')")
    @GetMapping("/list")
    public TableDataInfo list(SmesSequenceProduce smesSequenceProduce)
    {
        startPage();
        List<SmesSequenceProduce> list = smesSequenceProduceService.selectSmesSequenceProduceList(smesSequenceProduce);
        return getDataTable(list);
    }

    /**
     * 导出自动生成序列管理列表
     */
    @PreAuthorize("@ss.hasPermi('systembasic:produceSequence:export')")
    @Log(title = "自动生成序列管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SmesSequenceProduce smesSequenceProduce)
    {
        List<SmesSequenceProduce> list = smesSequenceProduceService.selectSmesSequenceProduceList(smesSequenceProduce);
        ExcelUtil<SmesSequenceProduce> util = new ExcelUtil<SmesSequenceProduce>(SmesSequenceProduce.class);
        return util.exportExcel(list, "produceSequence");
    }

    /**
     * 获取自动生成序列管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('systembasic:produceSequence:query')")
    @GetMapping(value = "/{rowId}")
    public AjaxResult getInfo(@PathVariable("rowId") Long rowId)
    {
        return AjaxResult.success(smesSequenceProduceService.selectSmesSequenceProduceById(rowId));
    }

    /**
     * 新增自动生成序列管理
     */
    @PreAuthorize("@ss.hasPermi('systembasic:produceSequence:add')")
    @Log(title = "自动生成序列管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmesSequenceProduce smesSequenceProduce)
    {
        return toAjax(smesSequenceProduceService.insertSmesSequenceProduce(smesSequenceProduce));
    }

    /**
     * 修改自动生成序列管理
     */
    @PreAuthorize("@ss.hasPermi('systembasic:produceSequence:edit')")
    @Log(title = "自动生成序列管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmesSequenceProduce smesSequenceProduce)
    {
        return toAjax(smesSequenceProduceService.updateSmesSequenceProduce(smesSequenceProduce));
    }

    /**
     * 删除自动生成序列管理
     */
    @PreAuthorize("@ss.hasPermi('systembasic:produceSequence:remove')")
    @Log(title = "自动生成序列管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{rowIds}")
    public AjaxResult remove(@PathVariable Long[] rowIds)
    {
        return toAjax(smesSequenceProduceService.deleteSmesSequenceProduceByIds(rowIds));
    }
}